package com.lili.service;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.controller.request.*;
import com.lili.mapper.*;
import com.lili.po.*;
import com.lili.uitl.ConvertUtil;
import com.lili.uitl.ShiroUtils;
import com.lili.vo.XasGoodsCategoryListVo;
import com.lili.vo.XasGroupBuyRecordsVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class XasGoodsService {
    @Autowired
    XasGoodsCategoryListMapper xasGoodsCategoryListMapper;
    @Autowired
    XasGoodsBrandListMapper xasGoodsBrandListMapper;
    @Autowired
    XasGoodsPropListMapper xasGoodsPropListMapper;
    @Autowired
    XasGoodsPropValueListMapper xasGoodsPropValueListMapper;
    @Autowired
    XasGoodsPropConfigMapper xasGoodsPropConfigMapper;
    @Autowired
    XasGoodsSkuConfigMapper xasGoodsSkuConfigMapper;
    @Autowired
    XasGoodsListMapper xasGoodsListMapper;
    @Autowired
    XasHotSalesGoodsMapper xasHotSalesGoodsMapper;
    @Autowired
    XasLimitedGoodsMapper xasLimitedGoodsMapper;
    @Autowired
    XasNewGoodsMapper xasNewGoodsMapper;
    @Autowired
    XasRecommendGoodsMapper xasRecommendGoodsMapper;
    @Autowired
    XasActivityGoodsMapper xasActivityGoodsMapper;
    @Autowired
    XasGoodsCommentListMapper xasGoodsCommentListMapper;
    @Autowired
    XasGroupBuyGoodsMapper xasGroupBuyGoodsMapper;
    @Autowired
    XasTopRankGoodsMapper xasTopRankGoodsMapper;
    @Autowired
    XasGroupBuyJoinRecordsMapper xasGroupBuyJoinRecordsMapper;
    @Autowired
    XasGroupBuyRecordsMapper xasGroupBuyRecordsMapper;
    @Autowired
    UserService userService;


    //商品分类
    public List<XasGoodsCategoryList> findGoodsCategory(Integer pid) {
        LambdaQueryWrapper<XasGoodsCategoryList> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(XasGoodsCategoryList::getPid, pid);
        List<XasGoodsCategoryList> xasGoodsCategoryLists = xasGoodsCategoryListMapper.selectList(lambdaQueryWrapper);
        return xasGoodsCategoryLists;
    }


    public List<XasGoodsCategoryListVo> secGoodsCategory() {
        List<XasGoodsCategoryList> xasGoodsCategoryLists = findGoodsCategory(0);
        List<XasGoodsCategoryListVo> xasGoodsCategoryListVoList = ConvertUtil.copyTo(xasGoodsCategoryLists, XasGoodsCategoryListVo.class);
        for (XasGoodsCategoryListVo xasGoodsCategoryListVo : xasGoodsCategoryListVoList) {
            List<XasGoodsCategoryList> goodsCategory = findGoodsCategory(xasGoodsCategoryListVo.getId());
            List<XasGoodsCategoryListVo> xasGoodsCategoryListVos = ConvertUtil.copyTo(goodsCategory, XasGoodsCategoryListVo.class);
            xasGoodsCategoryListVo.setGoodsCategoryList(xasGoodsCategoryListVos);
        }
        return xasGoodsCategoryListVoList;
    }

    public List<XasGoodsCategoryListVo> thrGoodsCategory() {
        List<XasGoodsCategoryList> xasGoodsCategoryLists = findGoodsCategory(0);
        List<XasGoodsCategoryListVo> xasGoodsCategoryListVoList = ConvertUtil.copyTo(xasGoodsCategoryLists, XasGoodsCategoryListVo.class);
        for (XasGoodsCategoryListVo xasGoodsCategoryListVo : xasGoodsCategoryListVoList) {
            List<XasGoodsCategoryList> goodsCategory = findGoodsCategory(xasGoodsCategoryListVo.getId());
            List<XasGoodsCategoryListVo> xasGoodsCategoryListVos = ConvertUtil.copyTo(goodsCategory, XasGoodsCategoryListVo.class);
            for (XasGoodsCategoryListVo goodsCategoryListVo : xasGoodsCategoryListVos) {
                List<XasGoodsCategoryList> goodsCategoryThr = findGoodsCategory(goodsCategoryListVo.getId());
                List<XasGoodsCategoryListVo> xasGoodsCategoryListVosThr = ConvertUtil.copyTo(goodsCategoryThr, XasGoodsCategoryListVo.class);
                goodsCategoryListVo.setGoodsCategoryList(xasGoodsCategoryListVosThr);
            }
            xasGoodsCategoryListVo.setGoodsCategoryList(xasGoodsCategoryListVos);
        }
        return xasGoodsCategoryListVoList;
    }


    public IPage<XasGoodsCategoryList> selectGoodsCategory(XasGoodsCategoryRequest xasGoodsCategoryRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsCategoryRequest, page);
        IPage iPage = xasGoodsCategoryListMapper.selectGoodsCategory(page, xasGoodsCategoryRequest.getName());
        return iPage;
    }

    @Transactional
    public void addGoodsCategory(XasGoodsCategoryList xasGoodsCategoryList) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGoodsCategoryList.setCreateUser(userLoginName);
        xasGoodsCategoryList.setCreateTime(new Date());
        xasGoodsCategoryListMapper.insert(xasGoodsCategoryList);
    }

    @Transactional
    public void updateGoodsCategory(XasGoodsCategoryList xasGoodsCategoryList) {
        xasGoodsCategoryListMapper.updateById(xasGoodsCategoryList);
    }

    @Transactional
    public void delGoodsCategory(Integer id) {
        xasGoodsCategoryListMapper.deleteById(id);
    }
    //商品分类结束


    //商品品牌 查询按照品牌名开始

    public IPage<XasGoodsBrandList> selectXasGoodsBrand(XasGoodsBrandRequest xasGoodsBrandRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsBrandRequest, page);
        LambdaQueryWrapper<XasGoodsBrandList> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(xasGoodsBrandRequest.getName()), XasGoodsBrandList::getName, xasGoodsBrandRequest.getName());
        IPage<XasGoodsBrandList> iPage = xasGoodsBrandListMapper.selectPage(page, lambdaQueryWrapper);
        return iPage;
    }

    @Transactional
    public void addXasGoodsBrand(XasGoodsBrandList xasGoodsBrandList) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGoodsBrandList.setCreateUser(userLoginName);
        xasGoodsBrandList.setCreateTime(new Date());
        xasGoodsBrandListMapper.insert(xasGoodsBrandList);
    }

    @Transactional
    public void updateXasGoodsBrand(XasGoodsBrandList xasGoodsBrandList) {
        xasGoodsBrandListMapper.updateById(xasGoodsBrandList);
    }

    @Transactional
    public void delXasGoodsBrand(Integer id) {
        xasGoodsBrandListMapper.deleteById(id);
    }
    //查询按照品牌名结束

    //商品属性开始
    public IPage<XasGoodsPropList> selectXasGoodsProp(XasGoodsPropRequest xasGoodsPropRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsPropRequest, page);
        LambdaQueryWrapper<XasGoodsPropList> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(xasGoodsPropRequest.getName()), XasGoodsPropList::getName, xasGoodsPropRequest.getName());
        IPage iPage = xasGoodsPropListMapper.selectPage(page, lambdaQueryWrapper);
        return iPage;
    }

    public List<XasGoodsPropList> selectAllXasGoodsProp() {
        return xasGoodsPropListMapper.selectList(null);
    }


    @Transactional
    public boolean addXasGoodsProp(XasGoodsPropList xasGoodsPropList) {
//        LambdaQueryWrapper<XasGoodsPropList> lambdaQueryWrapper = Wrappers.lambdaQuery();
//        lambdaQueryWrapper.eq(XasGoodsPropList::getName, xasGoodsPropList.getName());
//        XasGoodsPropList xasGoodsPropListRe = xasGoodsPropListMapper.selectOne(lambdaQueryWrapper);
//        if (xasGoodsPropListRe != null) {
//            return false;
//        }
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGoodsPropList.setCreateUser(userLoginName);
        xasGoodsPropList.setCreateTime(new Date());
        xasGoodsPropListMapper.insert(xasGoodsPropList);
        return true;
    }

    @Transactional
    public void updateXasGoodsProp(XasGoodsPropList xasGoodsPropList) {
        xasGoodsPropListMapper.updateById(xasGoodsPropList);
    }

    @Transactional
    public void delXasGoodsProp(Integer id) {
        xasGoodsPropListMapper.deleteById(id);
    }
    //商品属性结束


    //商品属性值开始
    public IPage<XasGoodsPropValueList> selectXasGoodsPropValue(XasGoodsPropValueRequest xasGoodsPropValueRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsPropValueRequest, page);
        IPage iPage = xasGoodsPropValueListMapper.selectXasGoodsPropValue(page, xasGoodsPropValueRequest.getName());
        return iPage;
    }


    @Transactional
    public void addXasGoodsPropValue(XasGoodsPropValueList xasGoodsPropValueList) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGoodsPropValueList.setCreateUser(userLoginName);
        xasGoodsPropValueList.setCreateTime(new Date());
        xasGoodsPropValueListMapper.insert(xasGoodsPropValueList);
    }

    @Transactional
    public void updateXasGoodsPropValue(XasGoodsPropValueList xasGoodsPropValueList) {
        xasGoodsPropValueListMapper.updateById(xasGoodsPropValueList);
    }

    @Transactional
    public void delXasGoodsPropValue(Integer id) {
        xasGoodsPropValueListMapper.deleteById(id);
    }
    //商品属性值结束


    //商品属性配置开始
    //查询按照商品名和商品属性名
    public IPage<XasGoodsPropConfig> selectXasGoodsPropConfig(XasGoodsPropConfigRequest xasGoodsPropConfigRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsPropConfigRequest, page);
        IPage iPage = xasGoodsPropConfigMapper.selectXasGoodsPropConfig(page, xasGoodsPropConfigRequest.getName(), xasGoodsPropConfigRequest.getPropName());
        return iPage;
    }

    @Transactional
    public boolean addXasGoodsPropConfig(XasGoodsPropConfig xasGoodsPropConfig) {
        LambdaQueryWrapper<XasGoodsPropConfig> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(XasGoodsPropConfig::getGid, xasGoodsPropConfig.getGid());
        lambdaQueryWrapper.eq(XasGoodsPropConfig::getPid, xasGoodsPropConfig.getPid());
        XasGoodsPropConfig xasGoodsPropConfigRe = xasGoodsPropConfigMapper.selectOne(lambdaQueryWrapper);
        if (xasGoodsPropConfigRe != null) {
            return false;
        }
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGoodsPropConfig.setCreateUser(userLoginName);
        xasGoodsPropConfig.setCreateTime(new Date());
        xasGoodsPropConfigMapper.insert(xasGoodsPropConfig);
        return true;
    }

    @Transactional
    public void updateXasGoodsPropConfig(XasGoodsPropConfig xasGoodsPropConfig) {
        xasGoodsPropConfigMapper.updateById(xasGoodsPropConfig);
    }

    @Transactional
    public void delXasGoodsPropConfig(Integer id) {
        xasGoodsPropConfigMapper.deleteById(id);
    }
    //商品属性配置结束

    //商品SKU 开始
    public IPage<XasGoodsSkuConfig> selectXasGoodsSkuConfig(XasGoodsSkuConfigRequest xasGoodsSkuConfigRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsSkuConfigRequest, page);
        IPage iPage = xasGoodsSkuConfigMapper.selectXasGoodsSkuConfig(page, xasGoodsSkuConfigRequest.getName());
        return iPage;
    }


    public List<XasGoodsSkuConfig> selectXasGoodsSkuConfigByGid(Integer gid) {
        return xasGoodsSkuConfigMapper.selectXasGoodsSkuConfigByGid(gid);
    }

    public List<XasGoodsPropList> selectXasGoodsSkuPropConfig(Integer gid) {
        List<XasGoodsPropList> xasGoodsPropLists = xasGoodsPropListMapper.selectXasGoodsSkuPropConfig(gid);
        return xasGoodsPropLists;
    }

    @Transactional
    public void addXasGoodsSkuConfig(XasGoodsSkuConfig xasGoodsSkuConfig) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGoodsSkuConfig.setCreateUser(userLoginName);
        xasGoodsSkuConfig.setCreateTime(new Date());
        xasGoodsSkuConfigMapper.insert(xasGoodsSkuConfig);
    }

    @Transactional
    public void updateXasGoodsSkuConfig(XasGoodsSkuConfig xasGoodsSkuConfig) {
        xasGoodsSkuConfigMapper.updateById(xasGoodsSkuConfig);
    }

    @Transactional
    public void delXasGoodsSkuConfig(Integer id) {
        xasGoodsSkuConfigMapper.deleteById(id);
    }
    //商品SKU 结束


    //商品信息开始
    public IPage<XasGoodsList> selectXasGoodsList(XasGoodsListRequest xasGoodsListRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsListRequest, page);
        IPage<XasGoodsList> iPage = xasGoodsListMapper.selectXasGoodsList(page, xasGoodsListRequest.getName(), xasGoodsListRequest.getPid());
        return iPage;
    }

    public List<XasGoodsCategoryListVo> selectAllXasGoodsList() {
        return selectAllXasGoodsList(0);
    }


    public List<XasGoodsCategoryListVo> selectAllXasGoodsList(Integer pid) {
        List<XasGoodsCategoryList> xasGoodsCategoryLists = findGoodsCategory(pid);
        List<XasGoodsCategoryListVo> xasGoodsCategoryListVoList = ConvertUtil.copyTo(xasGoodsCategoryLists, XasGoodsCategoryListVo.class);
        for (XasGoodsCategoryListVo xasGoodsCategoryListVo : xasGoodsCategoryListVoList) {
            List<XasGoodsCategoryList> goodsCategory = findGoodsCategory(xasGoodsCategoryListVo.getId());
            List<XasGoodsCategoryListVo> xasGoodsCategoryListVos = ConvertUtil.copyTo(goodsCategory, XasGoodsCategoryListVo.class);
            for (XasGoodsCategoryListVo goodsCategoryListVo : xasGoodsCategoryListVos) {
                List<XasGoodsCategoryList> goodsCategoryThr = findGoodsCategory(goodsCategoryListVo.getId());
                List<XasGoodsCategoryListVo> xasGoodsCategoryListVosThr = ConvertUtil.copyTo(goodsCategoryThr, XasGoodsCategoryListVo.class);
                for (XasGoodsCategoryListVo categoryListVo : xasGoodsCategoryListVosThr) {
                    LambdaQueryWrapper<XasGoodsList> lambdaQueryWrapper = Wrappers.lambdaQuery();
                    lambdaQueryWrapper.eq(XasGoodsList::getPid, categoryListVo.getId());
                    List<XasGoodsList> xasGoodsLists = xasGoodsListMapper.selectList(lambdaQueryWrapper);
                    categoryListVo.setXasGoodsList(xasGoodsLists);
                }
                goodsCategoryListVo.setGoodsCategoryList(xasGoodsCategoryListVosThr);
            }
            xasGoodsCategoryListVo.setGoodsCategoryList(xasGoodsCategoryListVos);
        }
        return xasGoodsCategoryListVoList;
    }


    public XasGoodsList selectXasGoodsListById(Integer id) {
        XasGoodsList xasGoodsList = xasGoodsListMapper.selectById(id);
        return xasGoodsList;
    }


    @Transactional
    public void addXasGoodsList(XasGoodsList xasGoodsList) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGoodsList.setCreateUser(userLoginName);
        xasGoodsList.setCreateTime(new Date());
        xasGoodsListMapper.insert(xasGoodsList);
    }

    @Transactional
    public void updateXasGoodsList(XasGoodsList xasGoodsList) {
        xasGoodsListMapper.updateById(xasGoodsList);
    }

    @Transactional
    public void delXasGoodsList(Integer id) {
        xasGoodsListMapper.deleteById(id);
    }
    //商品信息结束

    //拼团商品开始
    public IPage<XasGroupBuyRecordsVo> selectXasGroupBuyGoods(XasGroupBuyGoodsRequest xasGroupBuyGoodsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGroupBuyGoodsRequest, page);
        IPage<XasGroupBuyRecordsVo> iPage = xasGroupBuyRecordsMapper.selectXasGroupBuyRecords(page, xasGroupBuyGoodsRequest.getSkuId(), xasGroupBuyGoodsRequest.getStatus());
        return iPage;
    }

    @Transactional
    public void addXasGroupBuyGoods(XasGroupBuyGoods xasGroupBuyGoods) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasGroupBuyGoods.setCreateUser(userLoginName);
        xasGroupBuyGoods.setCreateTime(new Date());
        xasGroupBuyGoodsMapper.insert(xasGroupBuyGoods);
    }

    @Transactional
    public void updateXasGroupBuyGoods(XasGroupBuyGoods xasGroupBuyGoods) {
        xasGroupBuyGoodsMapper.updateById(xasGroupBuyGoods);
    }

    @Transactional
    public void delXasGroupBuyGoods(Integer id) {
        xasGroupBuyGoodsMapper.deleteById(id);
    }
    //拼团商品结束


    //热卖商品开始
    public IPage<XasHotSalesGoods> selectXasHotSalesGoods(XasHotSalesGoodsRequest xasHotSalesGoodsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasHotSalesGoodsRequest, page);
        IPage<XasHotSalesGoods> iPage = xasHotSalesGoodsMapper.selectXasHotSalesGoods(page, xasHotSalesGoodsRequest.getName());
        return iPage;
    }

    @Transactional
    public void addXasHotSalesGoods(XasHotSalesGoods xasHotSalesGoods) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasHotSalesGoods.setCreateUser(userLoginName);
        xasHotSalesGoods.setCreateTime(new Date());
        xasHotSalesGoodsMapper.insert(xasHotSalesGoods);
    }

    @Transactional
    public void updateXasHotSalesGoods(XasHotSalesGoods xasHotSalesGoods) {
        xasHotSalesGoodsMapper.updateById(xasHotSalesGoods);
    }

    @Transactional
    public void delXasHotSalesGoods(Integer id) {
        xasHotSalesGoodsMapper.deleteById(id);
    }

    //热卖商品结束

    //限购商品开始
    public IPage<XasLimitedGoods> selectXasLimitedGoods(XasLimitedGoodsRequest xasHotSalesGoodsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasHotSalesGoodsRequest, page);
        IPage<XasLimitedGoods> iPage = xasLimitedGoodsMapper.selectXasLimitedGoods(page, xasHotSalesGoodsRequest.getName());
        return iPage;
    }

    @Transactional
    public void addXasLimitedGoods(XasLimitedGoods xasLimitedGoods) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasLimitedGoods.setCreateUser(userLoginName);
        xasLimitedGoods.setCreateTime(new Date());
        xasLimitedGoodsMapper.insert(xasLimitedGoods);
    }

    @Transactional
    public void updateXasLimitedGoods(XasLimitedGoods xasHotSalesGoods) {
        xasLimitedGoodsMapper.updateById(xasHotSalesGoods);
    }

    @Transactional
    public void delXasLimitedGoods(Integer id) {
        xasLimitedGoodsMapper.deleteById(id);
    }
    //限购商品结束


    //新品上市开始
    public IPage<XasNewGoods> selectXasNewGoods(XasNewGoodsRequest xasHotSalesGoodsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasHotSalesGoodsRequest, page);
        IPage<XasNewGoods> iPage = xasNewGoodsMapper.selectXasNewGoods(page, xasHotSalesGoodsRequest.getName());
        return iPage;
    }

    @Transactional
    public void addXasNewGoods(XasNewGoods xasNewGoods) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasNewGoods.setCreateUser(userLoginName);
        xasNewGoods.setCreateTime(new Date());
        xasNewGoodsMapper.insert(xasNewGoods);
    }

    @Transactional
    public void updateXasNewGoods(XasNewGoods xasNewGoods) {
        xasNewGoodsMapper.updateById(xasNewGoods);
    }

    @Transactional
    public void delXasNewGoods(Integer id) {
        xasNewGoodsMapper.deleteById(id);
    }
    //新品上市结束

    //推荐商品开始
    public IPage<XasRecommendGoods> selectXasRecommendGoods(XasRecommendGoodsRequest xasRecommendGoodsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasRecommendGoodsRequest, page);
        IPage<XasRecommendGoods> iPage = xasRecommendGoodsMapper.selectXasRecommendGoods(page, xasRecommendGoodsRequest.getName());
        return iPage;
    }

    @Transactional
    public void addXasRecommendGoods(XasRecommendGoods xasRecommendGoods) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasRecommendGoods.setCreateUser(userLoginName);
        xasRecommendGoods.setCreateTime(new Date());
        xasRecommendGoodsMapper.insert(xasRecommendGoods);
    }

    @Transactional
    public void updateXasRecommendGoods(XasRecommendGoods xasRecommendGoods) {
        xasRecommendGoodsMapper.updateById(xasRecommendGoods);
    }

    @Transactional
    public void delXasRecommendGoods(Integer id) {
        xasRecommendGoodsMapper.deleteById(id);
    }
    //推荐商品结束

    //活动商品开始

    public IPage<XasActivityGoods> selectXasActivityGoods(XasActivityGoodsRequest xasActivityGoodsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasActivityGoodsRequest, page);
        IPage<XasActivityGoods> iPage = xasActivityGoodsMapper.selectXasActivityGoods(page, xasActivityGoodsRequest.getName());
        return iPage;
    }

    @Transactional
    public void addXasActivityGoods(XasActivityGoods xasActivityGoods) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasActivityGoods.setCreateUser(userLoginName);
        xasActivityGoods.setCreateTime(new Date());
        xasActivityGoodsMapper.insert(xasActivityGoods);
    }

    @Transactional
    public void updateXasActivityGoods(XasActivityGoods xasActivityGoods) {
        xasActivityGoodsMapper.updateById(xasActivityGoods);
    }

    @Transactional
    public void delXasActivityGoods(Integer id) {
        xasActivityGoodsMapper.deleteById(id);
    }
    //活动商品结束


    //商品评价开始
    public IPage<XasGoodsCommentList> selectXasGoodsCommentList(XasGoodsCommentListRequest
                                                                        xasGoodsCommentListRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGoodsCommentListRequest, page);
        IPage<XasGoodsCommentList> iPage = xasGoodsCommentListMapper.selectXasGoodsCommentList(page, xasGoodsCommentListRequest.getName());
        return iPage;
    }

    public void addXasTopRankGoods(XasTopRankGoods xasTopRankGoods) {
        String userLoginName = ShiroUtils.getUserLoginName(userService);
        xasTopRankGoods.setCreateUser(userLoginName);
        xasTopRankGoods.setCreateTime(new Date());
        xasTopRankGoodsMapper.insert(xasTopRankGoods);
    }

    public IPage<XasTopRankGoods> selectXasTopRankGoods(XasTopRankGoodsRequest xasTopRankGoodsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasTopRankGoodsRequest, page);
        IPage<XasTopRankGoods> iPage = xasTopRankGoodsMapper.selectXasTopRankGoods(page, xasTopRankGoodsRequest.getName());
        return iPage;

    }

    public void updateXasTopRankGoods(XasTopRankGoods xasTopRankGoods) {
        xasTopRankGoodsMapper.updateById(xasTopRankGoods);
    }

    public void delXasTopRankGoods(Integer id) {
        xasTopRankGoodsMapper.deleteById(id);
    }

    public IPage<XasGroupBuyJoinRecords> selectXasGroupBuyJoinRecords(XasGroupBuyJoinRecordsRequest
                                                                              xasGroupBuyJoinRecordsRequest) {
        Page page = new Page();
        BeanUtils.copyProperties(xasGroupBuyJoinRecordsRequest, page);
        IPage<XasGroupBuyJoinRecords> iPage = xasGroupBuyJoinRecordsMapper.selectXasGroupBuyJoinRecords(page, xasGroupBuyJoinRecordsRequest.getGbId());
        return iPage;
    }

    public void examineXasGoodsCommentList(Integer id, Integer status) {
        XasGoodsCommentList xasGoodsCommentList = new XasGoodsCommentList();
        xasGoodsCommentList.setId(id);
        xasGoodsCommentList.setStatus(status);
        xasGoodsCommentListMapper.updateById(xasGoodsCommentList);
    }


//    @Transactional
//    public void addXasGoodsCommentList(XasGoodsCommentList xasGoodsCommentList) {
//        xasGoodsCommentListMapper.insert(xasGoodsCommentList);
//    }
//
//    @Transactional
//    public void updateXasGoodsCommentList(XasGoodsCommentList xasGoodsCommentList) {
//        xasGoodsCommentListMapper.updateById(xasGoodsCommentList);
//    }
//
//    @Transactional
//    public void delXasGoodsCommentList(Integer id) {
//        xasGoodsCommentListMapper.deleteById(id);
//    }


    //商品评价结束

    //商品分享记录开始
    //商品分享记录结束
}
